import useThrottleFn from 'hooks/use-throttle-fn';
import { ThrottleOptions } from 'hooks/use-throttle/throttleOptions';
import useUpdateEffect from 'hooks/use-update-effect';
import { EffectCallback, DependencyList, useState, useEffect } from 'react';
export default (
    effect: EffectCallback,
    deps?: DependencyList,
    options?: ThrottleOptions
) => {
    const [flag, setFlag] = useState({})
    
    const { run } = useThrottleFn(() => {
        setFlag({})
    }, options)

    useEffect(() => {
        return run()
    }, deps)

    useUpdateEffect(effect, [flag])
}